﻿// This code is released under the BSD license.
namespace PugLib.UI.Controls
{
    using System.Collections.Generic;
    using System.Drawing;

    public static class PugDialogFactory
    {
        public static PugDialogButton Ok
        {
            get
            {
                PugDialogButton button = new PugDialogButton
                                             {
                                                 TextPrimary = Strings.OK,
                                                 TextSecondary = string.Empty,
                                                 Result = PugDialogResult.Ok,
                                                 //Image = Images.OK
                                             };
                return button;
            }
        }

        public static PugDialogButton Cancel
        {
            get
            {
                PugDialogButton button = new PugDialogButton
                                             {
                                                 TextPrimary = Strings.Cancel,
                                                 TextSecondary = string.Empty,
                                                 Result = PugDialogResult.Cancel,
                                                 // Image = Images.No
                                             };
                return button;
            }
        }

        public static PugDialogButton Yes
        {
            get
            {
                PugDialogButton button = new PugDialogButton
                                             {
                                                 TextPrimary = Strings.Yes,
                                                 TextSecondary = string.Empty,
                                                 Result = PugDialogResult.Yes,
                                                 // Image = Images.OK
                                             };
                return button;
            }
        }

        public static PugDialogButton No
        {
            get
            {
                PugDialogButton button = new PugDialogButton
                                             {
                                                 TextPrimary = Strings.No,
                                                 TextSecondary = string.Empty,
                                                 Result = PugDialogResult.No,
                                                 // Image = Images.No
                                             };
                return button;
            }
        }

        public static PugDialogButton Maybe
        {
            get
            {
                PugDialogButton button = new PugDialogButton
                                             {
                                                 TextPrimary = Strings.Maybe,
                                                 TextSecondary = string.Empty,
                                                 Result = PugDialogResult.Maybe,
                                                 //Image = Images.Help
                                             };
                return button;
            }
        }

        internal static Image CreateImage(PugDialogIcon icon)
        {
            switch (icon)
            {
                case PugDialogIcon.Asterisk:
                    return Images.New;
                case PugDialogIcon.Error:
                case PugDialogIcon.Exclamation:
                case PugDialogIcon.Warning:
                    return Images.Important;
                case PugDialogIcon.Information:
                    return Images.Info;
                case PugDialogIcon.Question:
                    return Images.Help;
                case PugDialogIcon.Stop:
                    return Images.Delete;
                default:
                    return Images.Blank;
            }
        }


        internal static IEnumerable<PugDialogButton> CreateButtons(PugDialogButtons buttons)
        {
            List<PugDialogButton> dialogButtons = new List<PugDialogButton>();
            switch (buttons)
            {
                case PugDialogButtons.OkCancel:
                    dialogButtons.Add(Ok);
                    dialogButtons.Add(Cancel);
                    break;
                case PugDialogButtons.YesNo:
                    dialogButtons.Add(Yes);
                    dialogButtons.Add(No);
                    break;
                case PugDialogButtons.YesNoMaybe:
                    dialogButtons.Add(Yes);
                    dialogButtons.Add(No);
                    dialogButtons.Add(Maybe);
                    break;
                case PugDialogButtons.YesNoCancel:
                    dialogButtons.Add(Yes);
                    dialogButtons.Add(No);
                    dialogButtons.Add(Cancel);
                    break;
                default:
                    dialogButtons.Add(Ok);
                    break;
            }
            return dialogButtons;
        }
    }
}